﻿using System;
using System.Linq;

namespace NanoERP.Infrastructure
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class ModuleAttribute : Attribute
    {
        public ModuleAttribute(params string[] moduleName)
        {
            this.Names = moduleName;
        }

        public string[] Names { get; private set; }

        public static string[] GetModuleNames(object obj)
        {
            return GetModuleNames(obj.GetType());
        }

        public static string[] GetModuleNames(Type type)
        {
            var attr = Attribute.GetCustomAttribute(
                type, typeof(ModuleAttribute)) as ModuleAttribute;
            return attr == null ? new[] { type.Name } : attr.Names;
        }


    }
}